//
//  AdoutViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/1.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "AdoutViewModel.h"
#import "UsLogoViewTableViewCell.h"
#import "SetUpTableViewCell.h"
#import "OrderOperationView.h"

@interface AdoutViewModel ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray * leftTitleArr;
}
@end

@implementation AdoutViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        leftTitleArr = @[@"",@"检查更新",@"联系我们",@"汇款账号",@"钢来钢往介绍",@"意见反馈",@"钢来钢网用户服务使用协议"];
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.tableHeaderView = [self createHeaderView];
        [superView addSubview:tableView];
    }
    return self;
}

-(UIView *)createHeaderView{
    UIView * headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10))];
    headerView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
    return headerView;
}

#pragma mark -- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 7;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return kHeightProportion_In_iPhoneTriploid(167);
    }else{
        return kHeightProportion_In_iPhoneTriploid(44);
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
    if (indexPath.row == 0) {
        UsLogoViewTableViewCell * cell_logo = [UsLogoViewTableViewCell cellWithTableView:tableView];
        cell = cell_logo;
    }else{
        SetUpTableViewCell * cell_list = [SetUpTableViewCell cellWithTableView:tableView];
        cell_list.showPush = YES;
        cell_list.leftstring = leftTitleArr[indexPath.row];
        cell = cell_list;
    }
    [cell setSepartionLineWith:lineModel_Half];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        OrderOperationView * topView = [[OrderOperationView alloc] initWithPopOrderOperation:@[@"确定"] theTitleStr:@"当前为最新版本，无需更新！" theTosStr:@"1.修复了已知BUG\n2.修复部分机型闪退的问题"];
        [topView show];
    }
    if (self.delegate && [self.delegate respondsToSelector:@selector(adoutUsDidSelectRowAtIndexPath:)]) {
        [self.delegate adoutUsDidSelectRowAtIndexPath:indexPath];
    }
}

@end
